
version 15
capture log close
set more off
clear
clear matrix
clear mata

if c(username)=="WB485280" {
		glo rootdir		"C:\Users\wb485280\OneDrive - WBG\radicalization"
		}
if c(username)=="WB382635" {
		glo rootdir		"C:\Users\wb382635\Dropbox\Unemp & daesh"
		}
if c(username)=="WB452275" {
		glo rootdir		"C:\Users\WB452275\Dropbox\Projects\Unemp & daesh"
		}
if c(username)=="sarurchaudhary" {
		glo rootdir		"/Users/sarurchaudhary/Dropbox/Unemp & daesh"
		}
if c(username)=="kartikabhatia" {
			glo rootdir		"/Users/kartikabhatia/Dropbox/Before2019/Unemp & daesh"
			}
			
		glo	datadir     "${rootdir}/Data/Raw data"
		glo outdir		"${rootdir}/Data/Working datasets"
		glo dodir		"${rootdir}/Dofiles"
        
		cd "${outdir}"
		
	    log using wdi_prep, replace t

* ------------------------------------------------------------------------------
* Date : July 2017 [chkd oct 2021]


* Project : Mena Economic Monitor, Fall 2016 edition (MNACE, The World Bank)


* This do file prepares the WDI database for merge

* Database used : wdi_data_04-15.dta


* Output : wdi.dta

* ------------------------------------------------------------------------------


*                      ---------------------------
*                      ----------WDI Data---------
*                      ---------------------------


use "${datadir}/wdi_data_04-15.dta", clear //WDI data


* Keeping only countries and dropping regional and other WB estimates

drop in 721/768
drop in 805/864
drop in 841/852
drop in 1045/1056
drop in 1045/1056
drop in 1081/1092
drop in 1093/1140
drop in 1333/1380
drop in 1345/1356
drop in 1417/1452
drop in 1585/1632
drop in 1777/1788
drop in 1801/1824
drop in 1945/1968
drop in 2149/2160
drop in 2185/2208
drop in 2269/2304
drop in 2545/2556
drop in 2629/2640
drop in 1813/1824
drop in 481/492
drop in 85/96

* Renaming few countries

replace countryname = "Congo Kinshasa" if countryname=="Congo, Dem. Rep."
replace countryname = "Congo Brazzaville" if countryname=="Congo, Rep."
replace countryname = "Ivory Coast" if countryname=="Cote d'Ivoire"
replace countryname = "North Korea" if countryname=="Korea, Dem. People’s Rep."
replace countryname = "South Korea" if countryname=="Korea, Rep."
replace countryname = "Palestine" if countryname=="West Bank and Gaza"

 
 * Droping islands and small nations
 
 drop if countryname=="American Samoa"
 drop if countryname=="Andorra"
 drop if countryname=="Antigua and Barbuda"
 drop if countryname=="Aruba"
 drop if countryname=="Bahamas, The"
 drop if countryname=="Barbados"
 drop if countryname=="Bermuda"
 drop if countryname=="British Virgin Islands"
 drop if countryname=="Brunei Darussalam"
 drop if countryname=="Cabo Verde"
 drop if countryname=="Caribbean small states"
 drop if countryname=="Cayman Islands"
 drop if countryname=="Channel Islands"
 drop if countryname=="Curacao"
 drop if countryname=="Dominica"
 *drop if countryname=="Equatorial Guinea" 
 *drop if countryname=="Eritrea" 
 drop if countryname=="Faroe Islands"
 drop if countryname=="Fiji"
 drop if countryname=="French Polynesia"
* drop if countryname=="Gambia, The" 
 drop if countryname=="Gibraltar"
drop  if countryname=="Greenland"
 drop if countryname=="Grenada"
 drop if countryname=="Guam"
 *drop if countryname=="Guinea-Bissau" 
 drop if countryname=="Isle of Man"
 drop if countryname=="Kiribati"
 drop if countryname=="Liechtenstein"
 drop if countryname=="Macao SAR, China"
 drop if countryname=="Maldives"
 drop if countryname=="Marshall Islands"
 drop if countryname=="Micronesia, Fed. Sts."
 drop if countryname=="Monaco"
 drop if countryname=="Nauru"
 drop if countryname=="New Caledonia"
 *drop if countryname=="North Korea" 
 drop if countryname=="Northern Mariana Islands"
 drop if countryname=="Pacific island small states"
 drop if countryname=="Palau"
 drop if countryname=="Papua New Guinea"
 drop if countryname=="Samoa"
 drop if countryname=="San Marino"
 drop if countryname=="Sao Tome and Principe"
 drop if countryname=="Seychelles"
 drop if countryname=="Sint Maarten (Dutch part)"
 drop if countryname=="Solomon Islands"
 drop if countryname=="St. Kitts and Nevis"
 drop if countryname=="St. Lucia"
 drop if countryname=="St. Martin (French part)"
 drop if countryname=="St. Vincent and the Grenadines"
 drop if countryname=="Timor-Leste"
 drop if countryname=="Tonga"
 drop if countryname=="Turks and Caicos Islands"
 drop if countryname=="Tuvalu"
 drop if countryname=="Vanuatu"
 drop if countryname=="Virgin Islands (U.S.)"
 
 * Adding countries which are in gallup but not in WDI
 
 insobs 48, before(1)
 replace countryname = "Northern Cyprus" in 1/12
 replace time = 2004 in 1
 replace time = time[_n-1]+1  in 2/12

 replace countryname = "Somaliland" in 13/24
 replace time = 2004 in 13
 replace time = time[_n-1]+1  in 14/24

 replace countryname = "Taiwan" in 25/36
 replace time = 2004 in 25
 replace time = time[_n-1]+1  in 26/36

 replace countryname = "Nagorno Karabakh" in 37/48
 replace time = 2004 in 37
 replace time = time[_n-1]+1  in 38/48


 * Sorting countries

 sort countryname, stable

 * Creating numeric variable 'country' from string variable 'countryname' 
 
 encode countryname, gen(ctry) //171 countries
 move ctry countryname 
 
 * Renaming variable time
 
 rename time year
 
 sort ctry year 
 
 save "${outdir}/wdi.dta", replace
 
 log close
